#ifndef TCPDEVICE_H
#define TCPDEVICE_H

/**
 * @copyright Copyright (c) 2025 
 * CSG Digital Grid Technology (Guangdong) Co., Ltd.
 * @author zhouyan
 * @brief modbus-TCP协议相关函数定义
*/
#include "phylink.h"
#include "sys_inc.h"

class TcpDevicePrivate;
class TcpDevice : public IPhyLink
{
public:
    TcpDevice(const char * dev_name, const char * ip_addr, uint32_t port);
    ~TcpDevice();

    virtual bool isActived(void) const;
    virtual bool connect(int timeout);
    virtual void disconnect(void);

    virtual uint32_t read(void *buf, uint32_t max_byte, uint32_t timeout);
    virtual uint32_t write(const void *buf, uint32_t max_byte);
    virtual void clear(void);

    virtual void lock(void);
    virtual void unlock(void);
    virtual bool tryLock(void);
    virtual bool SwitchSettings(ComSettings *settings, bool isReopen = true) {return false;}
    virtual int async_read(uint8_t *RecvBuf, uint32_t max_byte, uint32_t i_RecvTimeoutS){return 0;}
private:
    TcpDevicePrivate *private_;
};

#endif // TCPDEVICE_H
